/*=====================================================================

  File:        Exception.h

---------------------------------------------------------------------

This file is part of the Microsoft MSDN Code Samples.

  Copyright (C) Microsoft Corporation 2002.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

=====================================================================*/

#pragma once

// ------------------------------ ** ------------------------------
//
//                         Using Statements
//
// ------------------------------ ** ------------------------------

using namespace System;
using namespace System::Runtime::Serialization;





namespace Microsoft
{
namespace Samples
{
namespace Security
{
namespace SSPI
{
	// ------------------------------ ** ------------------------------
	//
	//                          SSPIException
	//
	// ------------------------------ ** ------------------------------

	[SerializableAttribute]
	public __gc class SSPIException : public ApplicationException, public ISerializable
	{

	public:

		// constructor/destructor
		SSPIException(String *message, int errorCode)
		{
			this->message = message; 
			this->errorCode = errorCode;
		}

		SSPIException(SerializationInfo *info, StreamingContext context) : ApplicationException(info, context)
		{
			this->message = info->GetString(S"message");
			this->errorCode = info->GetInt32(S"errorCode");
		}



		// System.Exception method overrides
		virtual void GetObjectData(SerializationInfo *info, StreamingContext context)
		{
			ApplicationException::GetObjectData(info, context);

			info->AddValue(S"message", this->message);
			info->AddValue(S"errorCode", this->errorCode);
		}



		// System.Exception property overrides
		__property virtual String *get_Message()
		{
			Object* args __gc[] = { this->message, __box(this->errorCode) };
			String *msg = String::Format(S"{0}. Error Code = '{1:X}'.", args );
			return msg;
		}



		// public properties
		__property int get_ErrorCode()
		{
			return this->errorCode;
		}



	private:
		

		// private data members
		String *message;
		int errorCode;
	};





	// ------------------------------ ** ------------------------------
	//
	//                 DelegateNotSupportedByNTLMException
	//
	// ------------------------------ ** ------------------------------

	[SerializableAttribute]
	public __gc class DelegateNotSupportedByNTLMException : public ApplicationException, public ISerializable
	{

	public:

		// constructor/destructor
		DelegateNotSupportedByNTLMException()
		{
		}

		DelegateNotSupportedByNTLMException(SerializationInfo *info, StreamingContext context) : ApplicationException(info, context)
		{
		}



		// System.Exception method overrides
		virtual void GetObjectData(SerializationInfo *info, StreamingContext context)
		{
			ApplicationException::GetObjectData(info, context);
		}



		// System.Exception property overrides
		__property virtual String *get_Message()
		{
			return S"The DELEGATE context attribute has been specified where the security package is NTLM.  Delegate is not supported by NTLM.";
		}
	};
}
}
}
}